import { request } from '@umijs/max';

export const getAdminList = () => {
  return request('/api/admin');
};

export const editAdminInfoApi = (id, data) => {
  return request(`/api/admin/${id}`, {
    method: 'PATCH',
    data,
  });
};

// 判断当前账号名字是否可用
export const isLoginIdExisted = (loginId) => {
  return request(`/api/admin/adminIsExist/${loginId}`);
};

export const addAdminApi = (target) => {
  return request('/api/admin', {
    method: 'POST',
    data: target,
  });
};

// 删除管理员
export const delAdminApi = (id) => {
  return request(`/api/admin/${id}`, {
    method: 'DELETE',
  });
};

// 登录相关

// 获取验证码
//
export const getCaptchaApi = () => {
  return request('/res/captcha');
};

// 管理员登录
export const adminLoginApi = (data) => {
  return request('/api/admin/login', {
    method: 'POST',
    data,
  });
};
// 恢复登录
export const whoAmIApi = () => {
  return request('/api/admin/whoami');
};

// 根据id查询管理员信息
export const getAdminInfoApi = (id) => {
  return request(`/api/admin/${id}`);
};
